<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;

use App\Models\Goods;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Admin\CatesController;

use DB;

class DetailController extends Controller
{

    public function getIndex(Request $request)
    {

        $details = Goods::find($request->id)->toArray();

        $cates = CatesController::getCatesByPid(0);
        $new = DB::table('goods')->skip(0)->take(6)->orderBy('created_at','desc')->get();
        $sale = DB::table('goods')->skip(0)->take(3)->orderBy('sale_num','desc')->get();
        $hot = DB::table('goods')->skip(0)->take(3)->orderBy('visit_num','desc')->get();
        $best = DB::table('goods')->skip(0)->take(4)->where('is_best',1)->orderBy('created_at','desc')->get();
        return view('Home/Detail/index',[
            'details'=>$details,
            'cates'=>$cates,
            'hot'=>$hot,
            'new'=>$new,
            'sale'=>$sale,
            'best'=>$best
        ]);
    }

}
